﻿using Angle.Krill.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Angle.Krill.WinFile
{
    public partial class NewFolder : ShadowForm
    {
        private string folderPath;

        public NewFolder(string folderPath)
        {
            InitializeComponent();

            this.Initialize();

            this.folderPath = folderPath;
        }

        private void Initialize()
        {
            this.Icon = ImageHelper.ConvertToIcon(ImageHelper.FolderIcon);
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            string fileName = this.txtFileName.Text.Trim();
            if (string.IsNullOrEmpty(fileName))
            {
                this.txtFileName.Focus();
            }

            string filePath = Path.Combine(this.folderPath, fileName);
            FileHelper.CreateFolder(filePath, () =>
            {
                this.Warn("已存在相同文件夹");
            }, () =>
            {
                this.Success("文件夹创建成功");
            });
        }
    }
}
